<template>
	<view>
		<view class="shaixuan">
			<view class="left">
				<view class="" @click="tab(1)" :class="{click:tabindex == 1}">
					最新
				</view>
				<view class="" @click="tab(2)" :class="{click:tabindex == 2}">
					综合
				</view>
			</view>
			<view class="right">
				<view class="typeselet">
					<picker @change="bindPickertype2" :value="typeInd2" range-key="label" :range="list">
						<text>{{banzu}}</text>
						<image src="../../static/icon/down2.png" mode=""></image>
					</picker>
				</view>
				<view class="typeselet" @click="typesele">
					<text>工种<template v-if="num">·</template>{{num}}</text>
					<image src="../../static/icon/down2.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="item_list" v-if="itemlist.length != 0">
			<view class="list" @click="goteam(item.id)" v-for="(item,index) in itemlist" :key="index">
				<view class="list_top">
					<view class="renzheng flex align" v-if="item.user.is_verify == 1 && user.group_id == 2">
						<image class="identIcon" src="../../static/icon/icon/home/renzheng.png" mode="aspectFill">
						</image>
						<text>已认证</text>
					</view>
					<view class="ipone">
						<image src="../../static/icon/tel.png" mode="widthFix"></image>
					</view>
					<image :src="item.user.avatar" mode="widthFix"></image>
					<view class="list_title">
						<view class="title_name">
							{{item.user.encoded}}
						</view>
					</view>
				</view>
				<view class="list_bottom">
					<view class="bottom_list flex">
						<view class="bottom_lists" v-for="(items,index) in item.troops_arr">
							{{items}}
						</view>
						<view class="bottom_lists2" v-for="(items,index) in item.work_arr">
							{{items}}
						</view>
					</view>
					<view class="bottom_content">
						{{item.introduce}}
					</view>
				</view>
			</view>

		</view>
		<view class="nolist" v-else>
			暂无内容~~
		</view>
		<m-picker mode="bottom" :show.sync="show" :range="list" @confirm="confirm"></m-picker>
	</view>
</template>

<script>
	import mPicker from '@/components/m-picker/m-picker.vue';
	const app = getApp()
	export default {
		data() {
			return {
				num:'',
				tabindex: 1,
				isshow: true,
				show: false,
				value: '',
				typeInd2: -1,
				banzu: '队伍类型',
				swiperList: [],
				iconslist: [],
				itemlist: [],
				list: [{
						label: '劳务班组',
						value: 200
					},
					{
						label: '专业分包',
						value: 201
					},
					{
						label: '技术团队',
						value: 202
					}
				],
				options:null,
				troops_ids:'',
				work_ids:'',
				page:1,
				total:0
			}
		},
		onLoad(options) {
			console.log(options)
			this.options = options
			if(options.troops_ids) this.troops_ids = options.troops_ids
			if(options.work_ids) {
				this.work_ids = options.work_ids
				
			}
			this.getitemlist()
		},
		onReady() {
			console.log('ready')
			if(this.options && this.options.name){
				uni.setNavigationBarTitle({
					title: this.options.name
				})
			}
			

		},
		onShow() {
			var _this = this
			
			this.num = this.work_ids?this.work_ids.split(',').length:""
			this.itemlist = []
			this.pageIndex = 1
			uni.getStorage({
				key: 'work_name',
				success: function(res) {
					console.log(res.data, '缓存--------------------');
					_this.num = res.data.length
					let arr = []
					res.data.forEach(item=>{
						arr.push(item.uid)
					})
					_this.work_ids = arr.join(',')
				}
			});
		},
		methods: {
			bindPickertype2(e) {
				console.log(e)
				this.typeInd2 = e.detail.value
				this.banzu = this.list[e.detail.value].label
				this.troops_ids = this.list[e.detail.value].value
				this.itemlist = []
				this.pageIndex = 1
				this.getitemlist()
			},
			open() {
				this.show = true
			},
			typesele() {
				uni.navigateTo({
					url: '/pages/typeSelection/typeSelection?pageurl=project'
				})
			},
			getitemlist() {
				let url
				if (app.globalData.user.group_id == 3) {
					url = 'addons/shopro/project/index'
				} else if (app.globalData.user.group_id == 2){
					url = 'addons/shopro/visiting_card/index'
				}
				let data = {
					"page": this.page,
					"num": 10,
					"order_by": this.tabindex == 1 ?'new' : 'allround',
					'troops_ids': this.troops_ids?this.troops_ids:'',
					"work_ids": this.work_ids?this.work_ids:''
				}
				if(url){
					app.getData(url, data).then(res => {
						console.log(res.data.data.data)
						this.itemlist = [...this.itemlist,...res.data.data.data]
						this.total = res.data.data.total
						// this.iconslist = res.data.data.data
					})
				}
				
			},
			tab(index) {
				this.tabindex = index
				this.itemlist = []
				this.pageIndex = 1
				this.getitemlist()
			},
			shows() {

				this.isshow = false
			},
			bindChange(e) {
				console.log(e)
			},
			confirm(e) {
				console.log(e)
			}

		},
		onReachBottom() {
		
			if(this.page * 10 <= this.total){
				this.page++
				this.getitemlist()
			}
			
		
		
		}

	}
</script>

<style lang="scss">
	.nolist {
		text-align: center;
		margin-top: 100rpx;
		// font-size: 32rpx;
		font-weight: 700;
	}

	.typeselet {
		background-color: #eee;
		border-radius: 8rpx;

		margin-left: 12rpx;

		image {
			width: 20rpx;
			height: 20rpx;
			margin-top: 12rpx;
		}
	}

	page {
		background-color: $uni-bg-color-grey;
		padding-top: 40rpx;
	}

	.swiperimg {
		width: 100%;

	}

	.hade {
		width: 100vw;
		height: 100rpx;
		line-height: 100rpx;
		background-color: $bg-color;
		color: #fff;
		padding-top: 76rpx;
		position: fixed;
		top: 0;
		z-index: 1000;
	}

	.inputs {

		background-color: $bg-color;
		height: 60rpx;
		padding: 0 20rpx;

		.input {
			background-color: #dec9d4;
			border-radius: 40rpx;
			display: flex;
			align-items: center;
			height: 50rpx;
			color: #fff;

			image {
				width: 20rpx;
				margin: 0 10rpx 0 20rpx;
			}

			font-size: 20rpx;
		}
	}

	.icons {
		display: flex;
		flex-wrap: wrap;
		padding: 20rpx;
		justify-content: flex-start;
		position: relative;
		top: -40rpx;
		background-color: #fff;

		.iconsall {
			image {
				width: 60rpx;
			}

			margin: 22rpx;
			text-align: center;
			font-size: 24rpx;
		}
	}

	.shaixuan {
		display: flex;
		padding: 0rpx 40rpx;
		justify-content: space-between;
		
		view {
			display: flex;
			justify-content: space-between;
			font-size: 28rpx;
			view {
				// margin: 10rpx;
				padding: 10rpx 20rpx;
			}

			.click {
				background-color: #fff;
				color: dodgerblue;
				font-weight: 500;
				font-size: 28rpx;
			}
		}
	}

	.item_list {
		padding: 20rpx;

		.list {
			background-color: #fff;
			padding: 20rpx;
			border-radius: 20rpx;
			margin-bottom: 20rpx;
			position: relative;

			.renzheng {
				position: absolute;
				top: 20rpx;
				right: 20rpx;
				color: #ffaa00;
				font-size: 20rpx;
			}

			.ipone {
				position: absolute;
				right: 20rpx;
				top: 50%;
				margin-top: -60rpx;

				image {
					width: 60rpx !important;
					margin: 0 !important;
				}

			}

			.list_top {
				display: flex;
				justify-content: flex-start;

				image {
					width: 100rpx;
					border-radius: 50%;
					margin-right: 20rpx;
				}

				.list_title {
					.title_name {
						font-size: 28rpx;
						font-weight: bold;
					}

					.title_dizhi {
						font-size: 24rpx;
						color: #333;
						margin-top: 18rpx;
						margin-left: 20rpx;
					}
				}
			}

			.list_bottom {
				.bottom_list {
					display: flex;
					justify-content: flex-start;
					margin: 20rpx 0;

					.bottom_lists,
					.bottom_lists2 {
						margin-right: 12rpx;
						font-size: 25rpx;
						text-align: center;
						padding: 4rpx 10rpx;
						background-color: #eee;
						margin-bottom: 12rpx;
					}
					
					.bottom_lists {
						color: var(--base);
						background: #E5F4FF;
						font-weight: 600;
					}
					.bottom_lists2 {
						width: 145rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
				}

				.bottom_content {
					font-size: 22rpx;
					color: #333;
					font-weight: 500;
				}
			}





		}
	}

	.mengceng {
		position: fixed;
		background-color: rgba(0, 0, 0, .8);
		width: 100vw;
		height: 100vh;
		top: 0;
		left: 0;
		z-index: 1001;



		.mengcengcontent {
			padding: 20rpx;
			// width: 86vw;/
			border-top-left-radius: 20rpx;
			border-top-right-radius: 20rpx;

			.alltitle {
				font-size: 36rpx;
				font-weight: 700;
			}

			position: absolute;
			background-color: #fff;
			// width: 100%;
			bottom: 0;

			.names {
				padding: 20rpx;
				margin: 20rpx 0;
				background-color: #5555ff;
				width: 90vw;
				border-radius: 20rpx;

				.titles {
					font-size: 36rpx;
					color: #fff;
				}

				.contents {
					font-size: 26rpx;
					color: #fff;
					margin-top: 20rpx;
				}
			}

		}
	}

	.popup_content {
		height: 400rpx;
		background-color: #fff;
	}

	.picker-view {
		width: 100%;
		height: 300rpx;

	}
</style>
